** Data reading and variable selection from raw data
** 1992 Russian General Social Survey

** 01. Reading data **

cap log close
clear all
set more off
cd /*insert you work directory here*/
use /*read your data here*/  


** 02. Consructing year and country variables **

ge year=1992
lab var year "survey year"

ge country=643
lab var country "ISO country code"
//Russia: 643 (see "ISO Country Codes.pdf) 


** 03. ID variables **

ge pid=REDID
lab var pid "person id"


** 04. Basic Demographics (Sex and Age/birth year) **

ge sex = GENDER
lab var sex "sex"
lab def sex 1 "male" 2 "female"
lab val sex sex

rename AGE age
lab var age "age"

ge birthyr = year - age

lab var birthyr "Year of Birth"

** 05. Siblings **

* number of brothers/sisters does not include respondent

*number of natural siblings*
ge numsibs_natural = .
replace numsibs_natural = 0 if V212_10A == 2
replace numsibs_natural = V212_10B if V212_10A == 1 & V212_10B != 99

lab def sibs_nat 6 "6 or more"
lab val numsibs_natural sibs_nat

lab var numsibs_natural "Number of natural siblings"


*number of step siblings*
ge numsibs_step = .
replace numsibs_step = 0 if V212_11A == 2
replace numsibs_step = V212_11B if V212_11A == 1 & V212_11B != 99

lab def sibs_step 6 "6 or more"
lab val numsibs_step sibs_step

lab var numsibs_step "Number of step siblings"


*Total number of siblings*
ge nsibs = (numsibs_natural + numsibs_step)
replace nsibs = 6 if nsibs > 6 & nsibs < .

lab def sibs 6 "6 or more"
lab val nsibs sibs

lab var nsibs "Total number of siblings"


** 06. Own education **

rename EDCENSUS educ_cat

lab var educ_cat "Level of education - Census Categories"

**missing**

replace educ_cat = . if educ_cat == 9

ge educ_yrs = .
replace educ_yrs = 6 if educ_cat == 1
replace educ_yrs = 8 if educ_cat == 2
replace educ_yrs = 10 if educ_cat == 3
replace educ_yrs = 11 if educ_cat == 4
replace educ_yrs = 14 if educ_cat == 5
replace educ_yrs = 15 if educ_cat == 6

lab var educ_yrs "Years of education completed respondent"

//label respondent education

lab var educ_cat "highest level of education completed"


** 07. Parents' education: Father and/or Mother **

**Code labels not available - have included the variable nonetheless**

rename V247_1E faeduc_cat

rename V247_2E moeduc_cat

lab var faeduc_cat "Father's level of education - No Labels"

lab var moeduc_cat "Mother's level of education - No Labels"


** 08. Own occupation **

rename OCCMAIN occ_isco

rename OCCMAINC occ_code

lab var occ_code "Occupational Category Condensed (Same scale as parental occupation)"

lab var occ_isco "ISCO 88 Occupational Category"

*Employment Status - employed is current occupational coding present, unemployed if indicates unemployed*

ge emp_stat = .
replace emp_stat = 1 if occ_code != .
replace emp_stat = 0 if OCCUNEM != .

lab var emp_stat "Current Employment Status"

lab def emp_statL 0 "Not presently in employment" 1 "In paid employment"

lab val emp_stat emp_statL


** 09. Parents' occupation **

rename OCCPOPC faocc_code

rename OCCMOMC moocc_code

lab var faocc_code "Father's Occupational Category"

lab var moocc_code "Mother's Occupational Category"

replace faocc_code = . if faocc_code == 99

replace moocc_code = . if moocc_code == 99


** 10. Tabulate the Identified Variables **

log using /*read your data here*/, replace text

** Data reading and variable selection from raw data
** RUSSIA 1992 General Social Survey

** Sex **
tab sex

** Age, Birth Year **
sum age birthyr, d

** Siblings **
sum nsibs numsibs_step numsibs_natural, d

** R's Own Education **
tab1 educ_cat educ_yrs

** Parental Education **
tab1 faeduc_cat moeduc_cat

** R's Own Occupation **
tab1 occ_code emp_stat

** Parent's Occupation **
tab1 faocc_code moocc_code

log close

** 11. Keep the identified variables only

keep year country pid sex age ///
	 nsibs numsibs_step numsibs_natural ///
	 educ_cat educ_yrs faeduc_cat moeduc_cat ///
	 occ_code emp_stat faocc_code moocc_code


** 12. Save the Data File **

saveold /*insert you work directory here*/, replace


**Create ISCED Education Variable**


ge educ_ISCED = .
replace educ_ISCED = 100 if educ_cat  == 1
replace educ_ISCED = 200 if educ_cat  == 2
replace educ_ISCED = 300 if educ_cat  == 3
replace educ_ISCED = 450 if educ_cat  == 4
replace educ_ISCED = 500 if educ_cat  == 5
replace educ_ISCED = 650 if educ_cat  == 6
